package kr.hyunist.androidcomplete01saeildamil.ch16;

import kr.hyunist.androidcomplete01saeildamil.*;
import android.app.*;
import android.content.*;
import android.content.DialogInterface.OnClickListener;
import android.os.*;
import android.view.*;
import android.widget.*;

public class CustomDialogTest extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.alertdialogtest);

	}

	public void mOnClick(View v){
		switch(v.getId()){
		case R.id.alertdialogtestbtn3:
			final LinearLayout linear = (LinearLayout) View.inflate(this, R.layout.ordertest, null);
			
			new AlertDialog.Builder(this).setTitle("주문 정보를 입력").setView(linear).setIcon(R.drawable.ic_launcher).setPositiveButton("확인", new DialogInterface.OnClickListener() {
				
				@Override
				public void onClick(DialogInterface dialog, int which) {
					EditText product = (EditText) linear.findViewById(R.id.customdialoget1);
					EditText num = (EditText) linear.findViewById(R.id.customdialoget2);
					CheckBox chk = (CheckBox) linear.findViewById(R.id.customdialogchk);
					TextView tv = (TextView) findViewById(R.id.alertdialogtv);
					
					tv.setText("주문정보 : " + product.getText() + " 제품, 수량 : " + num.getText() + "개." + (chk.isChecked()? "착불결제":""));
				}
				
			}).setNegativeButton("취소", new OnClickListener() {
				
				@Override
				public void onClick(DialogInterface dialog, int which) {
					TextView tv = (TextView) findViewById(R.id.alertdialogtv);
					
					tv.setText("사용자에 의한 취소");
				}
				
			}).show();
			break;
		}
	}
}
